﻿using NLog;
using System;


namespace NLogManager
{
    public class LogHelper
    {
        private static readonly Logger _log = LogManager.GetLogger("");

        public static void Debug(string msg,Exception ex = null)
        {
            if(ex is null)
            {
                _log.Debug($"#【日志消息】：[{msg}]");
            }
            else
            {
                _log.Debug(ex,$"#【日志消息】：[{msg}]");
            }
        }

        public static void Info(string msg,Exception ex = null)
        {
            if (ex is null)
            {
                _log.Info($"#【日志消息】：[{msg}]");
            }
            else
            {
                _log.Info(ex, $"#【日志消息】：[{msg}]");
            }
        }

        public static void Error(string msg ,Exception ex = null)
        {
            if (ex is null)
            {
                _log.Error($"#【日志消息】：[{msg}]");
            }
            else
            {
                _log.Error(ex, $"#【日志消息】：[{msg}]");
            }
        }

        public static void Fatal(string msg, Exception ex = null)
        {
            if (ex is null)
            {
                
                _log.Fatal($"#【日志消息】：[{msg}]");
            }
            else
            {
                _log.Fatal(ex, $"#【日志消息】：[{msg}]");
            }
        }
    }
}
